// define my ajax namespace

function Ajax(){}



if(window.XMLHttpRequest){
	Ajax.xmlhttp = new XMLHttpRequest();
}else{
	Ajax.xmlhttp = new ActiveObject("Microsoft.XMLHTTP");
}


Ajax.sendGET = function(url, obj_param, func_success,func_fail,func_finally, async){

	var xmlhttp = Ajax.xmlhttp;
	
	// prepare the call back function
	xmlhttp.onreadystatechange = function(){
		if(xmlhttp.readyState == 4 ){
			if(xmlhttp.status == 200){
				func_success(xmlhttp.responseText);
			}else{
				func_fail(xmlhttp.responseText);
			}
			func_finally(xmlhttp.responseText);	
		}
	}

	// prepare parameters
	var params="";	
	for(var name in obj_param){
		var pair = name+"="+encodeURIComponent(obj_param[name])+"&";
		params = params + pair;
	}
	
	
	url = url +"?"+params;
	
	var isSendAsync = true;
	
	if(typeof async != "undefined"){
		isSendAsync = async;
	}
	
	xmlhttp.open("GET",url,isSendAsync);
	xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xmlhttp.send();
		
	
}



Ajax.urlParam = function(url, obj_param){
	// prepare parameters
	var params="";	
	for(var name in obj_param){
		var pair = name+"="+encodeURIComponent(obj_param[name])+"&";
		params = params + pair;
	}
		
	url = url +"?"+params;
	
	return url;
}


Ajax.test = function(url, obj_param, func_success,func_fail,func_finally, async){
	
	if( typeof async == "undefined"){
		alert("true");
	}else{
		alert("else")
	}
	
	
	
}
